<?php

namespace app\admin\controller;

use think\Controller;
use think\Request;
use  gmars\rbac\Rbac;
use think\Db;
use app\admin\controller\Base;
use think\facade\Session;

class Admin extends Base
{

    public function index()
    {
        // $this->assign('name',Session::get('name'));
        // $this->assign('name','ThinkPHP');
        return $this->fetch();
    }

    public function welcome()
    {
        $time=time();
        $this->assign('time',$time);
        return $this->fetch();
    }

    public function welcome1()
    {
        return $this->fetch();
    }

    public function cate()
    {
        $rbac = new Rbac();
        $res=$rbac->getPermissionCategory([['status', '=', 1],['pid', '=', 0]]);
      
        foreach($res as $k=>$v)
        {
    
           $result= Db::table('permission_category')->where('status',  1)->where('pid',$v['id'])->select();
           $res[$k]['cid']=$result;
   
        }

   
        $this->assign('res',$res);
        return $this->fetch();
    }

    public function list()
    {
        return $this->fetch();
    }

    public function role()
    {
        return $this->fetch();
    }
    
    public function rule()
    {
        $res=  Db::table('permission')->alias('a')
        ->field('a.id,a.name,b.name as uname,a.path')
        ->join('permission_category b ','b.id= a.category_id')
        ->select();
        
        $this->assign('res',$res);

    //    dump( $res);
        return $this->fetch();
    }
    
    public function catadd()
    {
        return $this->fetch();
    }


}
